﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CsrdAPI.Csrd;

namespace CsrdAPI.Common
{
    public static class ShopHelper
    {
        /// <summary>
        /// 获取店铺ID字符串（''km00001''）
        /// </summary>
        /// <returns></returns>
        public static string ShopParamStr(string BalaceDate)
        {
            var beginDate = Convert.ToDateTime(BalaceDate + "-01");
            var endDate = beginDate.AddMonths(1).AddDays(1);
            var csrd = new CsrdEntities();
            var query = csrd.Csrd_Client.Where(t => t.ContractBeginDate <= beginDate && t.ContractEndDate >= endDate).ToList();
            if (query.Count == 0) return "";
            var result = query.Aggregate("(", (current, shop) => current + $"''{shop.ShopID}'',");
            result = result.TrimEnd(',') + ")";
            return result;
        }
    }
}
